using System;
using System.Collections.Generic;
using System.Text;

namespace IGGCore
{
    /// <summary>
    /// The current status of a game
    /// </summary>
    public class GameStatus
    {
        private string m_status;
        private Indicator m_indicator;
        private string m_reason;
        private int inning;
        private int outs;
        private bool inningTop;
        private int balls;
        private int strikes;

        private List<HomeRun> m_homeRuns;
        private Player m_currentBatter;
        private Player m_currentPitcher;
        private Player m_oppositePitcher;
        private Player m_winningPitcher;
        private Player m_losingPitcher;
        private Player m_savingPitcher;
        private string m_lastPbp;
        private Player m_onDeck;
        private Player m_inHole;
        private Player[] m_runners;

        /// <summary>
        /// Constructor
        /// </summary>
        public GameStatus()
        {
            m_homeRuns = new List<HomeRun>();
            m_runners = new Player[3];
        }

        /// <summary>
        /// Tell if this is the first batter of the inning.
        /// </summary>
        /// <returns>True if this is the first batter.</returns>
        public bool isInningStart()
        {
            bool start = false;
            if (outs == 0)
            {
                if (m_runners[0] == null && m_runners[1] == null && m_runners[2] == null)
                {
                    start = true;
                }
            }
            return start;
        }

        public Player[] RunnersOnBase
        {
            get { return m_runners; }
            set { m_runners = value; }
        }

        public Player InHole
        {
            get { return m_inHole; }
            set { m_inHole = value; }
        }

        public Player OnDeck
        {
            get { return m_onDeck; }
            set { m_onDeck = value; }
        }

        public Player WinningPitcher
        {
            get { return m_winningPitcher; }
            set { m_winningPitcher = value; }
        }

        public Player OppositePitcher
        {
            get { return m_oppositePitcher; }
            set { m_oppositePitcher = value; }
        }

        public Player LosingPitcher
        {
            get { return m_losingPitcher; }
            set { m_losingPitcher = value; }
        }

        public Player SavingPitcher
        {
            get { return m_savingPitcher; }
            set { m_savingPitcher = value; }
        }

        public Player CurrentBatter
        {
            get { return m_currentBatter; }
            set { m_currentBatter = value; }
        }

        public Player CurrentPitcher
        {
            get { return m_currentPitcher; }
            set { m_currentPitcher = value; }
        }

        public void AddHomeRun(HomeRun homerun)
        {
            if (m_homeRuns == null)
            {
                m_homeRuns = new List<HomeRun>();
            }
            m_homeRuns.Add(homerun);
        }

        public List<HomeRun> HomeRuns
        {
            get
            {
                return m_homeRuns;
            }
        }

        public string LastPbp
        {
            get { return m_lastPbp; }
            set { m_lastPbp = value; }
        }

        public string Status
        {
            get { return m_status; }
            set { m_status = value; }
        }
        
        public Indicator Indicator
        {
            get { return m_indicator; }
            set { m_indicator = value; }
        }
        
        public string Reason
        {
            get { return m_reason; }
            set { m_reason = value; }
        }
        
        public int Inning
        {
            get { return inning; }
            set { inning = value; }
        }
        
        public bool InningTop
        {
            get { return inningTop; }
            set { inningTop = value; }
        }
        
        public int Balls
        {
            get { return balls; }
            set { balls = value; }
        }
        
        public int Strikes
        {
            get { return strikes; }
            set { strikes = value; }
        }
        
        public int Outs
        {
            get { return outs; }
            set { outs = value; }
        }
    }
}
